package com.hoas.distributedlock.strategy.zookeeper;

import com.hoas.distributedlock.core.DisributedLock;
import com.hoas.distributedlock.core.DisributedLockStrategy;
import com.hoas.distributedlock.strategy.redis.RedisLock;
import org.I0Itec.zkclient.ZkClient;
import redis.clients.jedis.JedisPool;

public class ZookeeperLockStrategy extends DisributedLockStrategy {

    private ZkClient zkClient;

    private String prefix;

    public ZookeeperLockStrategy(String name, ZkClient zkClient, String prefix) {
        super(name);
        this.zkClient = zkClient;
        this.prefix = prefix;
    }

    protected DisributedLock create() {

        ZookeeperLock lock = new ZookeeperLock(zkClient);
        if (prefix != null && prefix.length() == 0) {
            lock.setPrefix( prefix );
        }
        return lock;
        
    }
}
